Repository navigation
feat(security): add opt-in context-leak canary tokens - #64
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ❌ Deployment failed View logs |
multillm-proxy | 4af6c28 | Oct 09 2026, 05:19 AM |
12f83c9
into
integrate/gateway-waves-1-5
Summary
Adds opt-in context-leak canary tokens. An opted-in managed request gets a request-specific marker inside a clearly labelled gateway system annotation. The gateway scans the provider's response for that marker and never lets it reach the client. With
CONTEXT_CANARY_MODEunset oroff(the default), or with no matching opt-in, prompts, responses, traces and logs are byte-for-byte unchanged, and no canary state is created.CONTEXT_CANARY_MODEisoff,logorblock. Empty means off; a malformed value is off with one warning that leaves the value out.CONTEXT_CANARY_POLICY_JSON(default{}) opts in exactroutesand authenticatedkeys. It is validated strictly, and setting the mode alone opts nothing in.systemfield for Messages, orinstructionsfor Responses. Existing instructions stay.context_canary_scan_failed.logremoves the marker and keeps delivering.blockreturns 502context_canary_leakbefore the response is committed. After streaming has begun, it sends a real SSE error event, without a fabricated completion or[DONE].Details are in
docs/context-canary.md.Wiring
worker/roleplay/endpoint.mjsthrough small named calls intoworker/context-canary.mjs, each of which returns its input unchanged while off.worker/roleplay/turn-trace.mjsgains acanaryevent that accepts only a valid digest, the rule and the trace ID.services/context_canary.py(prepare_request,finalize_response) and the WorkerprepareRequest/finalizeResponseare connected to the Flask managed pipeline and native Worker routes with the Wave 6 integration.Shared registrations
tests/test_context_canary_worker.mjsintest:worker.worker/context-canary.mjsin the edge module inventory.CONTEXT_CANARY_MODEandCONTEXT_CANARY_POLICY_JSONin the Container env keys.tests/helpers/load_cloudflare_worker.mjsmaps the endpoint's../context-canary.mjsimport.No migration, D1 tables, routes or browser-readable headers.
Tests
tests/test_context_canary.pyandtests/test_context_canary_worker.mjscover:context_canary_scan_failed;npm run test:worker: 1,656 passed.npm run test:integration: 7 passed.migrations:check(28 contiguous, additive migrations),test:deploy, free routes, client headers and thewrangler deploy --dry-runbundle all pass.tests/test_frontend_build.mjsfails locally because@tailwindcss/cliis not installed. It fails the same way on main.CI notes
python/nodejobs: the dependency-audit steps fail on every branch, including main. fix(deps): clear the CI dependency audit advisories #42 fixes that.AdmissionCoordinatorDurable Object migration, whichwrangler versions uploadcannot apply. This is expected untilwrangler deployruns on main.This is part of Wave 6. It is based on
integrate/gateway-waves-1-5, the Wave 5 integration branch (#60). The README line comes with the Wave 6 integration PR.